package arduino.eithernet.connection;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class EithernetConnectionManager {

	private final String _ip = "192.168.1.105";
	private final int _port = 8080;

	public String connectToArduino(String method) throws IOException {
		URL url = new URL("http", _ip, _port, method);
		URLConnection connection = url.openConnection();
		BufferedReader in = new BufferedReader(new InputStreamReader(
				connection.getInputStream()));
		StringBuilder result = new StringBuilder();
		String inputLine;
		while ((inputLine = in.readLine()) != null) {
			result.append(inputLine);
		}
		in.close();
		return result.toString();
	}

}
